Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Null vertex shaders and GPGPU processing

Author
Message
GrumpyOne
18
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 9th Aug 2014 04:32
I'm looking into using the GPU to do some number crunching through a shader in order to make use of the high degree of parallel processing in fragment shaders and their highly efficient vector manipulation. My idea is to potentially use set current bitmap and get image to grab the output data off a plane. I have found something puzzling in some of the HLSL shaders I have been looking at. Some have vertex shaders set to null in techniques (see below).



What I am a bit confused with is where does the output from the pixel shader go to? Without any vertexes or uvs I presume it isn't mapped to the object it is assigned to. If it goes into the screen buffer is there anyway to extract it?

GrumpyOne - the natural state of the programmer

GrumpyOne
18
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 9th Aug 2014 04:35
If you know of anyway of capturing output from the pixel shader without messing around with set current bitmap let me know! Cheers.

GrumpyOne - the natural state of the programmer

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Aug 2014 04:46
In lower level languages vertex shaders and pixel shaders are loaded and handled separately. It is entirely possible to load only a pixel shader and not have a vertex shader, just as it is possible to only have a vertex shader but no pixel shader.

DBP gives you no control over any parameters of the graphics pipeline other than shader constants, so there is no way (at least not without plugins) to use a pixel shader on its own.

In other languages it's possible to specify the extents of data being processed by the pixel shader. The work-around in DBP is to create a "screen quad".

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Aug 2014 17:52
You can certainly have a null vertex shader as in the following simple shader (a slightly modified version of a Dark Shader example):



DBPro simply uses the standard pipeline values in such cases.

Quote: "In lower level languages vertex shaders and pixel shaders are loaded and handled separately. It is entirely possible to load only a pixel shader and not have a vertex shader, just as it is possible to only have a vertex shader but no pixel shader."


I'm sure you can in DBPro too using the set pixel shader on and related commands. I haven't used them for several years so I don't know how well supported they are.



Powered by Free Banners
GrumpyOne
18
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 9th Aug 2014 19:56
Thanks everyone,

I am starting to get a handle on this, but just haven't got it working yet. I am trying to pass an image into a camera effect as input and output the result to an image. For my test case I am trying to generate a simplified perlin noise on the GPU and return it as an image in DBPro. I think there is something fundamental I don't understand about passing an image in.

The DBPro code is shown below and seems okay. You can see I pass in a random seed and the starting size for the image and I use memblock commands to precompute some random noise in an image which is then passed into the the camera shader as the last parameter of the load camera effect command. This code exports and image but it is entirely black and the same size as the screen:




The shader I am using is shown below. I suspect the issue is that I don't understand how to specify the image specified in the load camera effect command within the shader. I've tried changing the pixel shader to specify the pixel colour and yet strangely it always exports a black image.



Any suggestions are welcome.

GrumpyOne - the natural state of the programmer

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Aug 2014 21:35 Edited at: 9th Aug 2014 21:39
I don't think you can do that with a camera effect - it's designed to use the screen image as input image, as in a screen blur shader, and as far as I know you can't specify additional images.

You might be able to do what you want by rendering a fullscreen quad with your image so that the camera effect can then manipulate that image.

The camera effect commands were supposed to simplify this kind of task but my experience is that they make things more difficult. I usually use an object shader applied to a fullscreen quad followed by set camera to image for this sort of thing. You can then apply several additional images in the usual way.

Edit Just remembered. A while back Lee introduced the notion of a screen effect which can be used with the texture screen command. That may be just what you need. But you'd probably need a working example to start from - I haven't used that command myself.



Powered by Free Banners
GrumpyOne
18
Years of Service
User Offline
Joined: 27th Nov 2007
Location: London, UK
Posted: 10th Aug 2014 19:35
Cheers GG,

I saw that load camera effect had a load texture as a last parameter and assumed it could accept initial input from an image. Ah well, back to plan B. I'll create a plane, take the texture from the model, use an object effect, and then grab the result from the screen using set current bitmap. I suspect some fiddly sizing issues, but should be possible.

Anyway, as always, thanks for the help.

Products

Forester Pro - tree creator:
http://www.hptware.co.uk/forester.php
Medusa Pro - rock creator:
http://www.hptware.co.uk/medusa.php
Mr Normal - Normal map creator:
http://www.hptware.co.uk/mrnormal.php

GrumpyOne - the natural state of the programmer

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 12th Aug 2014 16:40
If you are looking for just number crunching with no video output, you can use OpenCL as it works with both OpenGL and DirectX. You just have to make sure your video card can support OpenCL 1.x.

Lot of youtube videos on this new tech.
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 13th Aug 2014 10:30
You can also extract particle shader parameters with:



Regards
Duke

Login to post a reply

Server time is: 2026-07-05 15:43:16
Your offset time is: 2026-07-05 15:43:16