add a custom shader to offscreenrender #1024
-
In vsgrendertotexture, I want to add a custom shader to offscreenrender, but after that it only works on the main_RenderGraph. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 4 replies
-
Back in August I implemented support fro selecting GraphicsPipline based in viewID so that each View could have it's own GraphicsPipeline, and then I added support for building seperate GraphicsPipeline per View by adding mask support into ShaderStage and GraphicsPipelineState which is used when creating the required vkPipeline objects for these. The mask on the ShaderState & GraphicsPipeineState is matched to each View's mask. I wrote up this work on this thread: #916 In a custom ShaderSet you can add the ShaderStage and GraphicsPipelineState with the approach masks. |
Beta Was this translation helpful? Give feedback.
-
It's very useful |
Beta Was this translation helpful? Give feedback.
-
I'm testing at vsganaglyphicstereo demo. void enableCustomShaderSets(vsg::Mask leftMask, vsg::Mask rightMask, vsg::ref_ptrvsg::Options options)
} A custom shader is used here The shaderstate in the custom shader also sets the corresponding mask vsg::Mask InMask = 0x1;
But both pipelines use custom shaders Am I using the wrong method |
Beta Was this translation helpful? Give feedback.
-
I want both pipelines to have their own shaders |
Beta Was this translation helpful? Give feedback.
-
I'm sorry. I didn't make it clear what I was going to do. In the vsgrendertotexture example, offscreenrenderpass and mainrenderpass use the same default shader. I want to add a custom shader to offscreenrenderpass. mainrenderpass uses the default shader. I will assign ids to all the mesh bodies through the offscreenRenderpass channel, and then color the mesh bodies based on the ids. |
Beta Was this translation helpful? Give feedback.
-
auto left_colorBlendState = vsg::RasterizationState::create();
pbrRight->defaultGraphicsPipelineStates = pipelineStates; I used two custom Shadersets, shadersetLeft and shadersetRight, was I wrong so that only one shaderset worked |
Beta Was this translation helpful? Give feedback.
-
Without all the code in front of my I don't know exactly what you are doing. However, as I have been saying all along your should use one ShaderSet as you are building on subgraph that will be rendering in both views. The key to having different rendering in each view is to use the ShaderStage::mask and GraphicsPipelineState::mask parameters to differentiate what will be used for the graphics pipeline used in each view. The vsganaglphhicstereo example illustrastates most of the key parts of what is required - one ShaderSet with multiple GraphicsPipelineState that use the mask to specialize it for each view. The only addition beyond this you need to make is set the ShaderStage::mask so adding multiple shaders stages to the single ShaderSet will map to appropriate ShaderSet stage used for the desired View. I can't keep saying this same thing over and over. Please read what I've written, and the vsganalgphicstereo example to see the illustration of what I'm talking about. |
Beta Was this translation helpful? Give feedback.
-
Steps as you said, I am in vsganalgphicstereo, add a pbr_ShaderSetLeft replacement for VSG: : createPhysicsBasedRenderingShaderSet (options); In pbr_ShaderSetLeft, leftMask is set for each of the two Shaderstages vsg::info("Local pbr_ShaderSet(", options, ")"); auto vertexShader = vsg::read_castvsg::ShaderStage("shaders/pickOffscreen.vert", options); vsg::Mask leftMask = 0x1; The result is that leftview and rightview have various GraphicsPipelineStates, but they both use pbr_ShaderSetLeft. What I want is that only leftview uses pbr_ShaderSetLeft. |
Beta Was this translation helpful? Give feedback.
-
I don;t know how many ways I can say the same thing,
You can only use one ShaderSet for building a single subgraph, that one
ShaderSet will need the left and right varians of the ShaderSet and
GraphicsPiplineState, Again follow the vsganaglyjpicsstereo example, it
doesn't have two ShaderSet, just one that is specialized for each View.
There is no left ShaderSet, right ShaderSet, there's is just one ShaderSet
that is specialized for each VIew based on the View' mask being matched to
the mask of the settings assigned to that ShaderSet.
|
Beta Was this translation helpful? Give feedback.
-
I am very sorry that I misunderstood your advice from the very beginning. Now it works properly |
Beta Was this translation helpful? Give feedback.
Back in August I implemented support fro selecting GraphicsPipline based in viewID so that each View could have it's own GraphicsPipeline, and then I added support for building seperate GraphicsPipeline per View by adding mask support into ShaderStage and GraphicsPipelineState which is used when creating the required vkPipeline objects for these. The mask on the ShaderState & GraphicsPipeineState is matched to each View's mask.
I wrote up this work on this thread: #916
In a custom ShaderSet you can add the ShaderStage and GraphicsPipelineState with the approach masks.