Author Topic: HLSL ps_3_0 issue  (Read 5440 times)

0 Members and 1 Guest are viewing this topic.

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
HLSL ps_3_0 issue
« on: June 22, 2012 »
Hi all, I have been trying to get a HLSL shader working in bmax, its the simple setup, render a fullscreen quad then use a pixelshader, the code is based off an dx9 example from rbz for c++ and iq's frameworks. I can get it to use the simple ps_2_0 shader that iq has in that framework fine, but any attempt I make at doing a ps_3_0 shader results in nothing being rendered but the background cls colour. Having not really done much HLSL stuff I am not sure if its something I am doing wrong or not.

This is the ps_2_0 shader code that works with ps_2_0 as the target.
Code: [Select]
float4 ps_main(float2 u:TEXCOORD):color
{
return float4(u.x,u.y,0.4,1);
}

If i change the shader target to ps_3_0 should this still compile and display?
I am not getting a compile error and the exe runs, I just dont get anything on screen. I have tried a few different shaders that are ment to be ps_3_0 ones but all give me the same blank screen so I am thinking there's something else i need to do for ps_3_0, probably in how the quad is rendered or some dx transform setting I am missing? but I havent found a simple example that uses this level shader.

Hopefully someone on here can point me in the right direction  :)

Cheers
Jon







Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: HLSL ps_3_0 issue
« Reply #1 on: June 24, 2012 »
I did some tests here and I also get this problem, not sure what is the cause (probably the ps shader isn't receiving correctly texture coordinates), the only way I can fix it is to first pass a vertex shader.

Or you can use vpos instead texcoord on ps_main:

Code: [Select]
float4 ps_main(float2 u:vpos):color
{
u.x/=1024; //screen width
u.y/=768; //screen height
return float4(u.x,u.y,0.4,1);
};
« Last Edit: June 24, 2012 by rbz »
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: HLSL ps_3_0 issue
« Reply #2 on: June 24, 2012 »
Thanks for taking a look rbz, I have also discovered that using a vertex shader fixed the issue and had just come on to post it incase anyone else had this issue.

I came across a similiar question to mine by someone using xna and the response they got was about ps_3_0 needing a vertex shader or it used some fallback that effectively makes it not render anything. So I tried it out and got the simple shader working. However a few others I have tried are not giving the results they should but at least getting something going is a start. Not really sure were I am going with this it just seemed like something cool to try and get working using bmax :)

I need to actually learn abit more about HLSL syntax and what it can and cant do to write something more interesting but now i atleast have a nice testbed to try stuff out.

Cheers
Jon

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: HLSL ps_3_0 issue
« Reply #3 on: June 24, 2012 »
WooT got a mandelbrot working in a shader :) Yeah its got an orbit trap on it which I dont like.
Gives me 60fps with vsync on, will see if i can pass in values so it can be zoomed in and moved about, could be fun.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: HLSL ps_3_0 issue
« Reply #4 on: June 24, 2012 »
That looks rather cool. Psychodelic colors, but cool none the less :)