Realtime GLSL

Discussions regarding Materials, Material-Compounds or Shaders, etc.
Post Reply
User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Realtime GLSL

Post by thefoofighter » 05 Sep 2019, 19:31

Hey Folks

I am trying to put together a PBR shader through GLSL for the Realtime OpenGL Viewport.

I am starting from scratch more or less since i havent seen one of these in SI yet but there are plenty of references and papers out there.

Anyway I have hit a road block. Basically the sample GLSL shaders are all using ftransform() to translate the vertices and show our meshes onscreen.

For me to be able to build a PBR shader without any restrictions I see that i can define #version 330 or even #version 450 core which is great it seems that both are supported but ftransform() is deprecated since i think version 140 which means that the user has the power to build the Model View Projection Matrix in c++ or i guess a script and then pass it as a uniform to the vertex shader at which point you would multiply the matrix by the position.xyz attribute which is provided by the Model/Mesh

Here is my code atm

#version 450

Vertex

Code: Select all

attribute vec3 position;

uniform mat4 mvpMatrix;

void main(void) 
{
	gl_Position = mvpMatrix * vec4(position, 1.0);
}
Fragment

Code: Select all

out vec4 colorOut;

void main(void) 
{
	colorOut = vec4(1.0);
	//gl_FragColor = vec4(1.0);
}
So yeah nothing really crazy going on here.

2019-09-05_1929.png
2019-09-05_1929.png (23.67 KiB) Viewed 3609 times
Now my question is. How do I for each object that has this material applied to it get the model, view & project matrices and multiply them either in a script/c++ or directly in the shader
Typically i am used to doing it prior in code and sending the resulting Matrix over.

Is this even possible in Softimage? Would I need to write some kind of plugin that would pass those values as a special render tree node?

Why am I even bothering? Well i use SI daily for work and It would be nice to preview my realtime shaders and how everything works before sending it onto the rendering engine. I know i could try this in a CG shader which may already send the values to the shader from some of the code I have looked at but for porting between SI and my target app GLSL would be the best option ^^

tl;dr: I need to get the multiplied result of the Model View Projection Matrices into a GLSL shader

Thanks for any help :)

User avatar
rray
Moderator
Posts: 1775
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Realtime GLSL

Post by rray » 06 Sep 2019, 15:18

Don't think it helps (I'm a big new noob to shader writing) but there's some stuff when you geneate a ultimapper preview

float4x4 WorldITXf : WorldInverseTranspose < string UIWidget = "None"; >;
float4x4 WVPXf : WorldViewProjection < string UIWidget = "None"; >;
float4x4 WorldXf : World < string UIWidget = "None"; >;
float4x4 ViewIXf : ViewInverse < string UIWidget = "None"; >;

it's .fx or .cgfx format though
softimage resources section updated Jan 5th 2024

User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Re: Realtime GLSL

Post by thefoofighter » 08 Sep 2019, 17:42

Ah the ultimapper preview, yeah looks like cg/fx, also saw some examples based on CG and some older ones in older sdks based on GLSL. I'll need to keep digging a little more :)

Thanks for pointing that out :)

Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests