Results 1 to 5 of 5

Thread: HLSL question

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    HLSL question

    Hi there,

    Im trying to make a working shader with FX files. (Im using ID3DXEffect)...
    My question:
    How can I set textures with my shader without using ID3DXEffect.SetTexture?
    I want to use Device.SetTexture.
    And how can I pass light information to my shader? My maps can have 0 to more than 100000 lights. How can I setup my shaders/application to use that informatino correctly

    Help me plz!!!

    (Im able to load shaders with a valid technique)

    EDIT: And how can I retreive the current view/projection matrices within my shader?
    NecroSOFT - End of line -

  2. #2

    Re: HLSL question

    Quote Originally Posted by NecroDOME
    Hi there,

    Im trying to make a working shader with FX files. (Im using ID3DXEffect)...
    My question:
    How can I set textures with my shader without using ID3DXEffect.SetTexture?
    I want to use Device.SetTexture.
    Just do Effect.BeginPass() and after that you can set your own texture (but in this case it's your responsibility to set it to right stage.

    And how can I pass light information to my shader? My maps can have 0 to more than 100000 lights. How can I setup my shaders/application to use that informatino correctly
    need more details here...

    EDIT: And how can I retreive the current view/projection matrices within my shader?
    You can't. You should declare global variable in FX file called like view_projection_matrix; set it by yourself in your pascal code; and access it in shader HLSL code.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    HLSL question

    Effect is a valid pointer to ID3DXEffect...
    [pascal]
    if HasShader then
    begin // Render with shaders
    Effect.SetTechnique;
    Effect.Shader._Begin(@Passes, 0); // begin shader

    for i := 0 to Passes-1 do
    begin
    Effect.Shader.BeginPass(i); // Render passes
    FScreen.Device.DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
    Effect.Shader.EndPass; // End render pass
    end;

    Effect.Shader._End; // end shader[/pascal]

    Is it possible to set textures outside the BeginPass?

    On the lights, some shaders are using a light. do I need to pass a light to the shader or can I just enable the lights trough DirectX?
    for example: I have a shader that uses bumpmapping from 1 light. The light is decleard as "float4 lightPos;". So it means I need to pass the light information to the shader? How do I do that is my object is lighten from 4 lights? Do I need to declear 4 light points in my shader? What if I have 2 object, 1 has 2 light, the other has 5 ?
    NecroSOFT - End of line -

  4. #4

    HLSL question

    You can only be sure that your texture is not overrided by effect framework if you call d3dDevice.SetTexture() after BeginPass() call. Why you don't want to set texture via effect.SetTexture()? It wil be set only once as if you call d3dDevice.SetTexture() outside your effect render cycle.


    Again, if you are using HLSL shader you should forget about fixed function part of D3D. There is no "API lights" for HLSL shader. So if you have shader calculating 2 lights you should declare array variables determining light properties by yourself and calculate all lighting by yourself too.

    To simplify your task you can use uniform variables that are resolved at compile time:
    Code:
    PS_OUTPUT RenderScene_ifs( VS_OUTPUT In, float2 p: VPOS, uniform int Lights = 2) 
    {
      for &#40;int i = 0; i<Lights; i++&#41;
      &#123; 
        // Do lighting
      &#125;
    &#125;
    
    technique Lights_1
    &#123;
        pass P0
        &#123;          
            PixelShader  = compile ps_3_0 RenderScene_ifs&#40; 1 &#41;;
        &#125;
    &#125;
    
    technique Lights_2
    &#123;
        pass P0
        &#123;          
            PixelShader  = compile ps_3_0 RenderScene_ifs&#40; 2 &#41;;
        &#125;
    &#125;

    PS. :!: In D3D10 there is no fixed function at all.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    HLSL question

    Thanks...

    I'll will try it when I got back from school.
    About DX 10, I read somthing about it that they scraped most of the fixed funtions... wel, I'm going to try it with Effect.SetTexture...

    and first I gonna try to get it woking with one light
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •