forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   С# (http://forum.boolean.name/forumdisplay.php?f=128)
-   -   Volume Rendering на XNA (Texture3D) (http://forum.boolean.name/showthread.php?t=14398)

ІГРОГРАЙКО 10.03.2011 23:15

Volume Rendering на XNA (Texture3D)
 
Вложений: 1
Привет всем!
У меня сильно наболел вопрос.:wild: Могу ли я конец концов пользоватса класом Texture3D для создания объемной текстуры с моей ничтожной Nvidia 5200 FX? (макс. шейдеры - 2.0)

Потому что при создании екземпляра:
Код:

public Texture3D (
        GraphicsDevice graphicsDevice,
        int width,
        int height,
        int depth,
        int numberLevels,
        TextureUsage usage,
        SurfaceFormat format
)

ошибка:

Вложение 12925

Кто небудь делал Volume Rendering на XNA?
Есть хороший пример тут. Но он у меня не работает и оч сложный...

Есть примеры создания 3Д Текстур на DirectX, OpenGL где не требуютса шейдеры 3.0. Но мне нужно сделать ето на XNA.

Посоветуйте мне как справитса с етой задачей. Пожалуйста!

Mr_F_ 10.03.2011 23:22

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Но он у меня не работает и оч сложный...
пример оч просто реализован, я его имплементировал, только не на ХНА. там же код шейдера есть. тебе остаётся только организовать несколько пассов в разные таргеты.

Цитата:

ошибка:
можно в принципе попробовать хранить 3д текстуру не в виде 3д текстуры, а в виде атласа, где все слои поочерёдно. но придётся немного изменить шейдер.

а ваще накопил бы 100 баксов и купил повменяемее видюху.

ABTOMAT 10.03.2011 23:31

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Сообщение от Mr_F_ (Сообщение 182270)
а ваще накопил бы 100 баксов и купил повменяемее видюху.

По-моему придётся весь комп менять лол. Видях на AGP уже не делают. Или искать по барахолкам что-нибудь типа GF7600















ІГРОГРАЙКО 11.03.2011 00:17

Ответ: Volume Rendering на XNA (Texture3D)
 
Спасибо за незамедлительный ответ!
Цитата:

Сообщение от Mr_F_ (Сообщение 182270)
пример оч просто реализован, я его имплементировал, только не на ХНА. там же код шейдера есть. тебе остаётся только организовать несколько пассов в разные таргеты.

Я пробовал изменять шейдер но ошибка та же.
Цитата:

Сообщение от Mr_F_ (Сообщение 182270)
можно в принципе попробовать хранить 3д текстуру не в виде 3д текстуры, а в виде атласа, где все слои поочерёдно. но придётся немного изменить шейдер.

Что ти имеешь в виду (атлас)? хранить как масив Texture2D?
Цитата:

Сообщение от Mr_F_ (Сообщение 182270)
а ваще накопил бы 100 баксов и купил повменяемее видюху.

А вот ето здесь не к чему. В первых Volume Rendering доступен и на видяхах похуже моей, во вторих АВТОМАТ прав, и ето не сильно изменит результат, так как мне и нужно добитса Volume Rendering на видео с шейдерами 2.0.

Есть еще какие ни-ть предложения. Или мне придетса писать собственный клас 3Д Текстур?:4to:

pax 11.03.2011 00:27

Ответ: Volume Rendering на XNA (Texture3D)
 
Почему SurfaceFormat.Vector4? твоя видеокарта конечно не будет поддерживать
Цитата:

(IEEE format) 128-bit float format using 32 bits for each channel (alpha, blue, green, red).
Попробуй другой, типа HalfVector4 или на худой конец Color

Mr_F_ 11.03.2011 00:32

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Что ти имеешь в виду (атлас)? хранить как масив Texture2D?
нет, в смысле у тебя одна большая 2д текстура, в которой лежат слои 3д текстуры по очереди. в шейдере смещаешь текскоорды - получаешь нужный кусок.

ІГРОГРАЙКО 11.03.2011 00:49

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 1
Спасибо!

SurfaceFormat.Color - пошло!
Только теперь надо как нибудь переделать метод загрузки .RAW:

Код:

        private void loadRAWFile8(FileStream file)
        {
            BinaryReader reader = new BinaryReader(file);

            byte[] buffer = new byte[mWidth * mHeight * mDepth];
            int size = sizeof(byte);

            reader.Read(buffer, 0, size * buffer.Length);

            reader.Close();

            //scale the scalar values to [0, 1]
            mScalars = new Color[buffer.Length];
            for (int i = 0; i < buffer.Length; i++)
            {
                mScalars[i] = new Color(0, 0, 0, (float)buffer[i] / byte.MaxValue);
            }

            mVolume.SetData(mScalars);
            mEffect.Parameters["Volume"].SetValue(mVolume);
        }

И наверно надо написать свой шейдер...<O>

К стате! Кто небудь пробовал загружать RAW с параметрами у файле DAT?
Вот как здесь:
Вложение 12926

ІГРОГРАЙКО 13.03.2011 13:59

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 2
Всем Привет!

У меня возник еще один вопрос:

Код:

float4x4 World;
float4x4 WorldViewProj;
float4x4 WorldInvTrans;

float3 StepSize;
int Iterations;

int Side = 2;

float4 ScaleFactor;

texture2D Front;
texture2D Back;
texture3D Volume;

sampler2D FrontS = sampler_state
{
        Texture = <Front>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
       
        AddressU = Border;                                // border sampling in U
    AddressV = Border;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler2D BackS = sampler_state
{
        Texture = <Back>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
       
        AddressU = Border;                                // border sampling in U
    AddressV = Border;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler3D VolumeS = sampler_state
{
        Texture = <Volume>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
       
        AddressU = Border;                                // border sampling in U
    AddressV = Border;                                // border sampling in V
    AddressW = Border;
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};


struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 texC                : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position                : POSITION0;
    float3 texC                        : TEXCOORD0;
    float4 pos                        : TEXCOORD1;
};

VertexShaderOutput PositionVS(VertexShaderInput input)
{
    VertexShaderOutput output;
       
    output.Position = mul(input.Position * ScaleFactor, WorldViewProj);
   
    output.texC = input.Position;
    output.pos = output.Position;

    return output;
}

float4 PositionPS(VertexShaderOutput input) : COLOR0
{
    return float4(input.texC, 1.0f);
}

float4 WireFramePS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, .5f, 0.0f, .85f);
}

//draws the front or back positions, or the ray direction through the volume
float4 DirectionPS(VertexShaderOutput input) : COLOR0
{
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f;
       
    float3 front = tex2D(FrontS, texC).rgb;
    float3 back = tex2D(BackS, texC).rgb;
       
        if(Side == 0)
        {
                return float4(front, .9f);
        }
        if(Side == 1)
        {
                return float4(back, .9f);
        }
   
    return float4(back - front, .9f);
}

float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
        //calculate projective texture coordinates
        //used to project the front and back position textures onto the cube
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f; 
       
    float3 front = tex2D(FrontS, texC).xyz;
    float3 back = tex2D(BackS, texC).xyz;
   
    float3 dir = normalize(back - front);
    float4 pos = float4(front, 0);
   
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
   
    float value = 0;
       
        float3 Step = dir * StepSize;
   
    for(int i = 0; i < Iterations; i++)
    {
                pos.w = 0;
                value = tex3Dlod(VolumeS, pos).r;
                               
                src = (float4)value;
                src.a *= .1f; //reduce the alpha to have a more transparent result
                                          //this needs to be adjusted based on the step size
                                          //i.e. the more steps we take, the faster the alpha will grow       
                       
                //Front to back blending
                // dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
                // dst.a  = dst.a  + (1 - dst.a) * src.a               
                src.rgb *= src.a;
                dst = (1.0f - dst.a)*src + dst;               
               
                //break from the loop when alpha gets high enough
                if(dst.a >= .95f)
                        break;       
               
                //advance the current position
                pos.xyz += Step;
               
                //break if the position is greater than <1, 1, 1>
                if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
                        break;
    }
   
    return dst;
}

technique RenderPosition
{
    pass Pass1
    {               
        VertexShader = compile vs_2_0 PositionVS();
        PixelShader = compile ps_2_0 PositionPS();
    }
}

technique RayCastDirection
{
    pass Pass1
    {               
        VertexShader = compile vs_2_0 PositionVS();
        PixelShader = compile ps_2_0 DirectionPS();
    }
}

technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_2_0 PositionVS();
        PixelShader = compile ps_3_0 RayCastSimplePS();
    }
}

technique WireFrame
{
    pass Pass1
    {               
        VertexShader = compile vs_2_0 PositionVS();
        PixelShader = compile ps_2_0 WireFramePS();
    }
}

В коде шейдера есть функция tex3Dlod которая строит 3Д Текстуру.
Но она не работает на моем компютере, так как нет доступных ей апаратных возможностей (шейдеров 3.0). Но програмка работеат и ее результат:

Вложение 12959

внутри пусто:

Вложение 12961

Что посоветуэте делать???

P.S. На основе примера VolumeRayCasting_101

Помогите пожалуйста!:dontknow:

pax 13.03.2011 14:21

Ответ: Volume Rendering на XNA (Texture3D)
 
Так просто tex3D используй.

ІГРОГРАЙКО 13.03.2011 19:06

Ответ: Volume Rendering на XNA (Texture3D)
 
Заменил:
Код:

value = tex3Dlod(VolumeS, pos).r;
на
Код:

value = tex3D(VolumeS, pos).r;
результат:

Код:

Ошибка        1        Building content threw TimeoutException: FXC took more than 20 seconds to compile!
  в WindowsEffectCompiler.WindowsEffectCompiler.Process(EffectContent input, ContentProcessorContext context) в E:\My Work\XNA to Silverlight\VolumeRayCasting_101\WindowsEffectCompiler\WindowsEffectCompiler.cs:строка 60
  в Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
  в Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
  в Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
  в Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
  в Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings)        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

Зменяю
Код:

technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_3_0 RayCastSimplePS();
    }
}

на
Код:

technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 RayCastSimplePS();
    }
}

Результат:
Код:

Ошибка        2        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(133,9): error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (33 iterations), use the [unroll(n)] attribute to force an exact higher number
E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(187,23): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed

        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

Есть еще какие небудь идеи?
Или в XNA нету возможности построить 3Д текстуры без шейдеров 3.0???

С нетерпением жду ваших ответов!

pax 13.03.2011 20:14

Ответ: Volume Rendering на XNA (Texture3D)
 
у тебя проблемы с циклом, а не с этой командой, читай внимательнее ошибки. Попробуй явно задать количество итераций.

ІГРОГРАЙКО 13.03.2011 21:07

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 1
Да... Спасибо! Но!

Код:

float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
        //calculate projective texture coordinates
        //used to project the front and back position textures onto the cube
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f; 
       
    float3 front = tex2D(FrontS, texC).xyz;
    float3 back = tex2D(BackS, texC).xyz;
   
    float3 dir = normalize(back - front);
    float4 pos = float4(front, 0);
   
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
   
    float value = 0;
       
        float3 Step = dir * StepSize;
   
    for(int i = 0; i < 10; i++)
    {
                pos.w = 0;
                value = tex3D(VolumeS, pos).r;
                               
                src = (float4)value;
                src.a *= .1f; //reduce the alpha to have a more transparent result
                                          //this needs to be adjusted based on the step size
                                          //i.e. the more steps we take, the faster the alpha will grow       
                       
                //Front to back blending
                // dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
                // dst.a  = dst.a  + (1 - dst.a) * src.a               
                src.rgb *= src.a;
                dst = (1.0f - dst.a)*src + dst;               
               
                //break from the loop when alpha gets high enough
                if(dst.a >= .95f)
                        break;       
               
                //advance the current position
                pos.xyz += Step;
               
                //break if the position is greater than <1, 1, 1>
                if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
                        break;
    }
   
    return dst;
}


technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 RayCastSimplePS();
    }
}
}

Все одно вылетает из за:

Код:

Ошибка        2        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(136,9): error X5426: Shader uses texture addressing operations in a dependency chain that is too complex for the target shader model (ps_2_0) to handle. 
ID3DXEffectCompiler: Compilation failed

        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

И если изменяю ps_2_0 на ps_3_0 Опять:

Вложение 12965

Что с етим делать???:dontknow:

pax 13.03.2011 21:49

Ответ: Volume Rendering на XNA (Texture3D)
 
Попробуй начать не с 10, а еще меньше посмотри на сколько можно для SM2.0,
Получается, что у тебя много операций выборки текстур.

И еще, шейдер не генерирует 3d текстуру, а делает из нее выборку. Позаботься, чтобы текстура была задана и не черная.

ІГРОГРАЙКО 14.03.2011 11:24

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 1
Да рах ты прав!
Запустилось у меня, но отрисовует только один шар:

Вложение 12972

Если:

Код:

float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
        //calculate projective texture coordinates
        //used to project the front and back position textures onto the cube
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f; 
       
    float3 front = tex2D(FrontS, texC).xyz;
    float3 back = tex2D(BackS, texC).xyz;
   
    float3 dir = normalize(back - front);
    float4 pos = float4(input.texC, 0);
   
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
   
    float value = 0;
       
        float3 Step = dir * StepSize;
   
    for(int i = 0; i < 2; i++)
    {
                pos.w = 0;
                value = tex3D(VolumeS, pos).r;
                               
                src = (float4)value;
                //src.a *= .1f; //reduce the alpha to have a more transparent result
                                          //this needs to be adjusted based on the step size
                                          //i.e. the more steps we take, the faster the alpha will grow       
                       
                //Front to back blending
                // dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
                // dst.a  = dst.a  + (1 - dst.a) * src.a               
                //src.rgb *= src.a;
                dst = (1.0f - dst.a)*src + dst;               
               
                //break from the loop when alpha gets high enough
                if(dst.a >= .9f)
                        break;       
               
                //advance the current position
                pos.xyz += Step;
               
                //break if the position is greater than <1, 1, 1>
                if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
                        break;
    }
   
    return dst;
}

то вилетает:

Код:

Ошибка        2        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(112,8): error X5608: Compiled shader code uses too many arithmetic instruction slots (70). Max. allowed by the target (ps_2_0) is 64.
E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(187,23): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed

        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

Что с етим делать?
Как быть? :dontknow:

pax 14.03.2011 12:23

Ответ: Volume Rendering на XNA (Texture3D)
 
ps3.0 либо оптимизация расчетов. У тебя превышен лимит инструкций для пиксельного шейдера 2.0 (у тебя 70 из 64 возможных).

ІГРОГРАЙКО 15.03.2011 00:47

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Сообщение от pax (Сообщение 182742)
ps3.0 либо оптимизация расчетов. У тебя превышен лимит инструкций для пиксельного шейдера 2.0 (у тебя 70 из 64 возможных).

Врят ли ето поможет..:unsure:

А если я напишу сам функцию построения 3Д текстуры без использования tex3D???
Не знаю зделаю ли я ето так же легко как на Блице но принцып 3Д текстуры я понял.

Например:
  • Создам 3 массивы полигонов (NX, NY и NZ).
  • К каждому полигону массива NX привяжу текстуру с файла соотвецтвенного слоя (с двух сторон).
  • Текстуру для полигонов масива NY и NZ сгенерирую как CLAMP UV и CLAMP VU тексур слоев массива NX.

Наверно тогда компилятор не будет возмущатса по поводу превишения лимита инструкций.
Как вам моя идея??? :rolleyes:

ІГРОГРАЙКО 17.03.2011 12:19

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 2
Сделал я то что думал.
И вот как оно виглядит:

Вложение 12993

У клас Volume.cs дописал:
PHP код:

VertexBuffer vertexBufferNX;
VertexBuffer vertexBufferNY;
VertexBuffer vertexBufferNZ;

VertexPositionColor[] pointListNX;
VertexPositionColor[] pointListNY;
VertexPositionColor[] pointListNZ;

int pointsNX;
int pointsNY;
int pointsNZ;

short[] triangleStripIndicesNXtriangleStripIndicesNYtriangleStripIndicesNZ;

...

protected 
override void LoadContent()
{
            
base.LoadContent();

            
pointsNX mHeight;
            
pointsNY mWidth;
            
pointsNZ mDepth;

            
pointListNX = new VertexPositionColor[pointsNX];
            
pointListNY = new VertexPositionColor[pointsNY];
            
pointListNZ = new VertexPositionColor[pointsNZ];

            for (
int ny 0ny mHeightny++)
            {
                for (
int nx 0nx 2nx++)
                {
                    for (
int nz 0nz 2nz++)
                    {
                        
pointListNX[(ny 4) + (nx 2) + nz] = new VertexPositionColor(new Vector3((float)nx, (float)(1.0f mHeight) * ny, (float)nz),Color.White);
                    }
                }
            }

            for (
int nx 0nx mWidthnx++)
            {
                for (
int ny 0ny 2ny++)
                {
                    for (
int nz 0nz 2nz++)
                    {
                        
pointListNY[(nx 4) + (ny 2) + nz] = new VertexPositionColor(new Vector3((float)(1.0f mWidth) * nx, (float)ny, (float)nz),Color.White);
                    }
                }
            }

            for (
int nz 0nz mDepthnz++)
            {
                for (
int nx 0nx 2nx++)
                {
                    for (
int ny 0ny 2ny++)
                    {
                        
pointListNZ[(nz 4) + (nx 2) + ny] = new VertexPositionColor(new Vector3((float)nx, (float)ny, (float)(1.0f mDepth) * nz),Color.White);
                    }
                }
            }

            
vertexBufferNX = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNX.LengthBufferUsage.None);
            
vertexBufferNX.SetData<VertexPositionColor>(pointListNX);

            
vertexBufferNY = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNY.LengthBufferUsage.None);
            
vertexBufferNY.SetData<VertexPositionColor>(pointListNY);

            
vertexBufferNZ = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNZ.LengthBufferUsage.None);
            
vertexBufferNZ.SetData<VertexPositionColor>(pointListNZ);

            
triangleStripIndicesNX = new short[pointsNX];
            
triangleStripIndicesNY = new short[pointsNY];
            
triangleStripIndicesNZ = new short[pointsNZ];

            for (
int y 0mHeighty++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNX[(4) + i] = (short)((4) + i);
                }
            }

            for (
int x 0mWidthx++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNY[(4) + i] = (short)((4) + i);
                }
            }

            for (
int z 0mDepthz++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNZ[(4) + i] = (short)((4) + i);
                }
            }


И метод отрисовки полигонов:
PHP код:

private void DrawTriangleStrip()
        {
            for (
int i 0pointListNX.Lengthi++)pointListNX[i].Color = new Color(1f,1f,1f,0.01f);

            for (
int nx 0nx mHeightnx++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNX,
                    
nx*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNX,
                    
nx*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }

            for (
int i 0pointListNY.Lengthi++)pointListNY[i].Color = new Color(1f1f1f0.01f);
            for (
int ny 0ny mWidthny++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNY,
                    
ny*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNY,
                    
ny*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }

            for (
int i 0pointListNZ.Lengthi++)pointListNZ[i].Color = new Color(1f1f1f0.01f);
            for (
int nz 0nz mDepthnz++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNZ,
                    
nz*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNZ,
                    
nz*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }
        } 

Подскажите только как убрать ети светла (R,G,B )???

Вложение 12994

pax 17.03.2011 12:53

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Сообщение от ІГРОГРАЙКО (Сообщение 183035)
Подскажите только как убрать ети светла (R,G,B )???

Эмм... :4to:

ІГРОГРАЙКО 17.03.2011 15:42

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 2
Ета цветовая фигня была в шейдере:
Код:

float4 PositionPS(VertexShaderOutput input) : COLOR0
{
    return float4(input.texC, 1.0f);
}

Теперь все ровно:
Код:

float4 PositionPS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, 1.0f, 1.0f, 0.1f);
}




Ну теперь самое сложное. Надо написать новую технику в шейдере, чтоб она привязывала каждий слой текстуры с файла к соотвецтвующему полигону...

Есть неплохой пример: How To: Create Custom Texture Effects
Етот кусок кода привязывает текстуру к всем граням куба:
Код:

// This code would go between a device BeginScene-EndScene block.
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
    pass.Begin();

    GraphicsDevice.DrawIndexedPrimitives(
        PrimitiveType.TriangleList,
        0,
        0,
        cubeVertices.Length,
        0,
        12
    );

    pass.End();
}
effect.End();

Но мне нужно привязывать каждому полигону соответствующую текстуру с RAW файла.
Вопрос:
1. Как добыть тексуры с файла для каждого полигона?
2. Как привязать каждому полигону отдельную текстуру?

ІГРОГРАЙКО 17.03.2011 23:51

Ответ: Volume Rendering на XNA (Texture3D)
 
Помогите мне пожалуйста!
Я не знаю как мне добыть масив Texture2D с RAW файла

Етот метод:
Код:

private void loadRAWFile16(FileStream file)
        {
            BinaryReader reader = new BinaryReader(file);

            ushort[] buffer = new ushort[mWidth * mHeight * mDepth];

            for (int i = 0; i < buffer.Length; i++)
                buffer[i] = reader.ReadUInt16();

            reader.Close();

            //scale the scalar values to [0, 1]
            mScalars = new float[buffer.Length];
            for (int i = 0; i < buffer.Length; i++)
            {
                mScalars[i] = (float)buffer[i] / byte.MaxValue;
            }

            mVolume.SetData(mScalars);
            mEffect.Parameters["Volume"].SetValue(mVolume);
        }

Считывает с RAW файла даные и заполняет екземпляр mVolume класа Texture3D:
Код:

mVolume = new Texture3D(Game.GraphicsDevice, mWidth, mHeight, mDepth, 0, TextureUsage.None, SurfaceFormat.Single);
А потом отсилает в шейдер к параметру Volume с типом Texture3D:
Код:

float4x4 World;
float4x4 WorldViewProj;
float4x4 WorldInvTrans;

float3 StepSize;
int Iterations;

int Side = 2;

float4 ScaleFactor;

texture2D Front;
texture2D Back;
texture3D Volume;

sampler2D FrontS = sampler_state
{
        Texture = <Front>;
        MinFilter = POINT;
        MagFilter = POINT;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler2D BackS = sampler_state
{
        Texture = <Back>;
        MinFilter = POINT;
        MagFilter = POINT;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler3D VolumeS = sampler_state
{
        Texture = <Volume>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    AddressW = CLAMP;
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};



struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 texC                : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position                : POSITION0;
    float3 texC                        : TEXCOORD0;
    float4 pos                        : TEXCOORD1;
};

VertexShaderOutput PositionVS(VertexShaderInput input)
{
    VertexShaderOutput output;
       
    output.Position = mul(input.Position * ScaleFactor, WorldViewProj);
   
    output.texC = input.Position;
    output.pos = output.Position;

    return output;
}

float4 PositionPS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, 1.0f, 1.0f, 0.1f);
}

float4 WireFramePS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, .5f, 0.0f, .85f);
}

//draws the front or back positions, or the ray direction through the volume
float4 DirectionPS(VertexShaderOutput input) : COLOR0
{
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f;
       
    float3 front = tex2D(FrontS, texC);
    float3 back = tex2D(BackS, texC);
       
        if(Side == 0)
        {
                return float4(front, .9f);
        }
        if(Side == 1)
        {
                return float4(back, .9f);
        }
   
    return float4(back - front, .9f);
}

float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
        //calculate projective texture coordinates
        //used to project the front and back position textures onto the cube
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f; 
       
    float3 front = tex2D(FrontS, texC).xyz;
    float3 back = tex2D(BackS, texC).xyz;
   
    float3 dir = normalize(back - front);
    float4 pos = float4(input.texC, 0);
   
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
   
    float value = 0;
       
        float3 Step = dir * StepSize;
   
    for(int i = 0; i < 1; i++)
    {
                pos.w = 0;
                value = tex3D(VolumeS, pos).r;
                               
                src = (float4)value;
                src.a *= .1f; //reduce the alpha to have a more transparent result
                                          //this needs to be adjusted based on the step size
                                          //i.e. the more steps we take, the faster the alpha will grow       
                       
                //Front to back blending
                // dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
                // dst.a  = dst.a  + (1 - dst.a) * src.a               
                //src.rgb *= src.a;
                dst = (1.0f - dst.a)*src + dst;               
               
                //break from the loop when alpha gets high enough
                if(dst.a >= .9f)
                        break;       
               
                //advance the current position
                pos.xyz += Step;
               
                //break if the position is greater than <1, 1, 1>
                if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
                        break;
    }
   
    return dst;
}

technique RenderPosition
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 PositionPS();
    }
}

technique RayCastDirection
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 DirectionPS();
    }
}

technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 RayCastSimplePS();
    }
}

technique WireFrame
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 WireFramePS();
    }
}

Вопрос:
Как зделать так чтобы даные с файла RAW наполнили массив Texture2D???

Жду ваших предложений!!! :SOS:

ІГРОГРАЙКО 18.03.2011 05:51

Ответ: Volume Rendering на XNA (Texture3D)
 
Ну вот я и релизовал часть свого хитрого плана:rolleyes: .
Метод загрузки RAW файла я переделал, чтоб он создавал масив Texture2D. Но есть проблема с параметром шейдера в которий я хочу сливать масив текстур. А точнее говоря я не знаю как переслать массив текстур в шейдер...

Код метода:
PHP код:

.
        private 
void loadRAWFile16(FileStream file)
        {
            
BinaryReader reader = new BinaryReader(file);

            
ushort[] buffer = new ushort[fWidth fHeight fDepth];

            for (
int i 0buffer.Lengthi++)
                
buffer[i] = reader.ReadUInt16();

            
reader.Close();

            
//scale the scalar values to [0, 1]
            
mScalars = new Color[buffer.Length];
            for (
int i 0buffer.Lengthi++)
            {
                
mScalars[i] = new Color(1f0f0f, ((float)buffer[i] / byte.MaxValue) * 0.1f);
            }

            
int wd mVolume[0].Width;
            
int hg mVolume[0].Height;

            for (
int i 0mHeighti++)
            {
                
int start * (wd hg);
                
mVolume[i].SetData<Color>(mScalarsstartwd hgSetDataOptions.None);
                
mVolume[i].Save("IMG_" ".tga"ImageFileFormat.Tga);
                
mEffect.Parameters["Volume"].SetValue(mVolume[i]);
            }
            
mScalars null;
        } 

Код шейдера:
Код:

float4x4 World;
float4x4 WorldViewProj;
float4x4 WorldInvTrans;

float3 StepSize;
int Iterations;

int Side = 2;

float4 ScaleFactor;

texture2D Front;
texture2D Back;
texture2D[] Volume;

sampler2D FrontS = sampler_state
{
        Texture = <Front>;
        MinFilter = POINT;
        MagFilter = POINT;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler2D BackS = sampler_state
{
        Texture = <Back>;
        MinFilter = POINT;
        MagFilter = POINT;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};

sampler3D VolumeS = sampler_state
{
        Texture = <Volume>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
       
        AddressU = CLAMP;                                // border sampling in U
    AddressV = CLAMP;                                // border sampling in V
    AddressW = CLAMP;
    BorderColor = float4(0,0,0,0);        // outside of border should be black
};


struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 texC                : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position                : POSITION0;
    float3 texC                        : TEXCOORD0;
    float4 pos                        : TEXCOORD1;
};

VertexShaderOutput PositionVS(VertexShaderInput input)
{
    VertexShaderOutput output;
       
    output.Position = mul(input.Position * ScaleFactor, WorldViewProj);
   
    output.texC = input.Position;
    output.pos = output.Position;

    return output;
}

float4 PositionPS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, 1.0f, 1.0f, 0.1f);
}

float4 WireFramePS(VertexShaderOutput input) : COLOR0
{
    return float4(1.0f, .5f, 0.0f, .85f);
}

//draws the front or back positions, or the ray direction through the volume
float4 DirectionPS(VertexShaderOutput input) : COLOR0
{
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f;
       
    float3 front = tex2D(FrontS, texC);
    float3 back = tex2D(BackS, texC);
       
        if(Side == 0)
        {
                return float4(front, .9f);
        }
        if(Side == 1)
        {
                return float4(back, .9f);
        }
   
    return float4(back - front, .9f);
}

float4 RayCastSimplePS(VertexShaderOutput input) : COLOR0
{
        //calculate projective texture coordinates
        //used to project the front and back position textures onto the cube
        float2 texC = input.pos.xy /= input.pos.w;
        texC.x =  0.5f*texC.x + 0.5f;
        texC.y = -0.5f*texC.y + 0.5f; 
       
    float3 front = tex2D(FrontS, texC).xyz;
    float3 back = tex2D(BackS, texC).xyz;
   
    float3 dir = normalize(back - front);
    float4 pos = float4(input.texC, 0);
   
    float4 dst = float4(0, 0, 0, 0);
    float4 src = 0;
   
    float value = 0;
       
        float3 Step = dir * StepSize;
   
    for(int i = 0; i < 1; i++)
    {
                pos.w = 0;
                value = tex3D(VolumeS, pos).r;
                               
                src = (float4)value;
                src.a *= .1f; //reduce the alpha to have a more transparent result
                                          //this needs to be adjusted based on the step size
                                          //i.e. the more steps we take, the faster the alpha will grow       
                       
                //Front to back blending
                // dst.rgb = dst.rgb + (1 - dst.a) * src.a * src.rgb
                // dst.a  = dst.a  + (1 - dst.a) * src.a               
                //src.rgb *= src.a;
                dst = (1.0f - dst.a)*src + dst;               
               
                //break from the loop when alpha gets high enough
                if(dst.a >= .9f)
                        break;       
               
                //advance the current position
                pos.xyz += Step;
               
                //break if the position is greater than <1, 1, 1>
                if(pos.x > 1.0f || pos.y > 1.0f || pos.z > 1.0f)
                        break;
    }
   
    return dst;
}

technique RenderPosition
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 PositionPS();
    }
}

technique RayCastDirection
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 DirectionPS();
    }
}

technique RayCastSimple
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 RayCastSimplePS();
    }
}

technique WireFrame
{
    pass Pass1
    {               
        VertexShader = compile vs_1_0 PositionVS();
        PixelShader = compile ps_2_0 WireFramePS();
    }
}

Вылетает ошибка:
Код:

Ошибка        2        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(15,10): error X3000: syntax error: unexpected token '['

        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

Я понял что так делать нелзя. Но а как нужно я не знаю.:dontknow:
Подскажыте мне как поступить?

pax 18.03.2011 11:16

Ответ: Volume Rendering на XNA (Texture3D)
 
нельзя в шейдере использовать массив текстур, ты же создавал 3d текстуру, почему отказался то?

ІГРОГРАЙКО 18.03.2011 17:37

Ответ: Volume Rendering на XNA (Texture3D)
 
Цитата:

Сообщение от pax (Сообщение 183156)
нельзя в шейдере использовать массив текстур, ты же создавал 3d текстуру, почему отказался то?

Отказался из за етого: :"(
Код:

Ошибка        2        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(112,8): error X5608: Compiled shader code uses too many arithmetic instruction slots (70). Max. allowed by the target (ps_2_0) is 64.
E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx(187,23): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed

        E:\My Work\XNA to Silverlight\VolumeRayCasting_101\VolumeRayCasting\Content\Shaders\RayCasting.fx        VolumeRayCasting

Ты говорил про оптимизацыю рашчетов, но ето поможет отрисовать только второй слой, а что делать с остальными 126??? Если вы мне предложите какой нибудь иной способ (полегче моего) создать и отрисовать 3Д текстуру я буду оч благодарен! ;)

ІГРОГРАЙКО 19.03.2011 06:47

Ответ: Volume Rendering на XNA (Texture3D)
 
Вложений: 10
Я опять обращаюсь к вам за помощю!

У меня есть 3 масива цветных даных с RAW файла:
Код:

        private Color[] mTextDataNX;
        private Color[] mTextDataNY;
        private Color[] mTextDataNZ;

Массив текстур:
Код:

        private Texture2D[] mTexture;

        mTexture = new Texture2D[fDepth];
        for (int i = 0; i < fDepth; i++)
        {
            mTexture[i] = new Texture2D(Game.GraphicsDevice, fWidth, fHeight, 0, TextureUsage.None, SurfaceFormat.Color);
        }

После заполнения масива текстур масивом цветных данных и сохранения их в файлы:
Код:

        int wd = mTexture[0].Width;
        int hg = mTexture[0].Height;
        for (int i = 0; i < fHeight; i++)
        {
            int start = i * (wd * hg);
            mTexture[i].SetData<Color>(mTextDataN*, start, wd * hg, SetDataOptions.None);
            mTexture[i].Save("IMG_" + i + ".tga", ImageFileFormat.Tga);
        }

Я получаю текстуры соотвецтвенных слоев:
mTextDataNX
Вложение 13011Вложение 13012Вложение 13013
mTextDataNY
Вложение 13014Вложение 13015Вложение 13016
mTextDataNZ
Вложение 13017Вложение 13018Вложение 13019
Как мне ети масивы цветных даных переобразовать в 3 большых текстуры? (атласы или как их там...)
Я пробовал:
Код:

        private Texture2D nTexture;

        int source = fWidth * fHeight * fDepth;
        int maxHeight = GraphicsDevice.GraphicsDeviceCapabilities.MaxTextureHeight;
        int maxWidth = GraphicsDevice.GraphicsDeviceCapabilities.MaxTextureWidth;
        for (mHeight = 2; mHeight < maxHeight; mHeight *= 2)
        {
            mWidth = source / mHeight;
            if (mWidth <= maxWidth)
                break;
        }
        nTexture = new Texture2D(Game.GraphicsDevice, mWidth, mHeight, 0, TextureUsage.None, SurfaceFormat.Color);

        int wd = nTexture.Width;
        int hg = nTexture.Height;
        nTexture.SetData<Color>(mTextDataNX, 0, hg * wd, SetDataOptions.None);
        nTexture.Save("MAP.tga", ImageFileFormat.Tga);

Но уменя получаетса вот такая фигня:
(оригинал 4096 х 512)
Вложение 13023
Как ето сделать коректно?

Помогите пожалуйста!

ІГРОГРАЙКО 09.04.2011 00:37

Ответ: Volume Rendering на XNA (Texture3D)
 
Добрый вечер!

У меня возник вопрос связаный с шейдером.

Код:
Код:

float4x4 WorldViewProj;

texture3D Volume;

sampler3D SVolume = sampler_state
{
        Texture = <Volume>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
};

struct VS_INPUT
{
    float4 Position : POSITION0;
};

struct VS_OUTPUT
{
    float4 Position : POSITION0;
    float4 pos : TEXCOORD0;
};

VS_OUTPUT PositionVS(VS_INPUT input)
{
    VS_OUTPUT output;
       
    output.Position = mul(input.Position, WorldViewProj);
    output.pos = input.Position;
   
    return output;
}

float4 PixelShaderFunction(VS_OUTPUT input) : COLOR0
{               
    float4 texColor = tex3D(SVolume,input.pos);
    return texColor;
}

technique BasicView
{
    pass Pass1
    {
        VertexShader = compile vs_1_1 PositionVS();
        PixelShader = compile ps_1_1 PixelShaderFunction();
    }
}

Мне нужно отрезать половину 3Д текстуры. Я подумал, что лучше всего ето можно осуществить умножением Альфа канала 3Д текстури на "0" в заданом промежутке:
Код:

float4x4 WorldViewProj;

texture3D Volume;

sampler3D SVolume = sampler_state
{
        Texture = <Volume>;
        MinFilter = LINEAR;
        MagFilter = LINEAR;
        MipFilter = LINEAR;
};

struct VS_INPUT
{
    float4 Position : POSITION0;
};

struct VS_OUTPUT
{
    float4 Position : POSITION0;
    float4 pos : TEXCOORD0;
};

VS_OUTPUT PositionVS(VS_INPUT input)
{
    VS_OUTPUT output;
       
    output.Position = mul(input.Position, WorldViewProj);
    output.pos = input.Position;
   
    return output;
}

float4 PixelShaderFunction(VS_OUTPUT input) : COLOR0
{
    float4 outColor;

    if(input.Position.x > 0.5f)
        outColor = float4(1,1,1,0);
    else
        outColor = float4(1,1,1,1);

               
    float4 texColor = tex3D(SVolume,input.pos);
    return texColor * outColor;
}

technique BasicView
{
    pass Pass1
    {
        VertexShader = compile vs_1_1 PositionVS();
        PixelShader = compile ps_1_1 PixelShaderFunction();
    }
}

Но при построении оно вилетает:
Код:

Ошибка        1        Errors compiling C:\Documents and Settings\Володя\Мои документы\Visual Studio 2008\Projects\Vol_Render\Vol_Render\Content\Shaders\VolumeRendering.fx:
C:\Documents and Settings\Володя\Мои документы\Visual Studio 2008\Projects\Vol_Render\Vol_Render\Content\Shaders\VolumeRendering.fx(20): error X4502: invalid reference to input semantic 'POSITION0'
C:\Documents and Settings\Володя\Мои документы\Visual Studio 2008\Projects\Vol_Render\Vol_Render\Content\Shaders\VolumeRendering.fx(52): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed        C:\Documents and Settings\Володя\Мои документы\Visual Studio 2008\Projects\Vol_Render\Vol_Render\Content\Shaders\VolumeRendering.fx        20        1        Vol_Render

Не понимаю почему???
Помогите исправить ошибку, пожалуйста!

pax 09.04.2011 00:58

Ответ: Volume Rendering на XNA (Texture3D)
 
ну так if(input.pos.x > 0.5f)
Ты же специально для этого скопировал значение output.pos = input.Position; в вершинном шейдере. POSITION0 не передать в пиксельный шейдер, только через текстурные слоты.


Часовой пояс GMT +4, время: 19:19.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Перевод: zCarot