Comments (7)
same style error also posted when bind static buffer use bufferview ,for example
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials") ->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));
from diligentengine.
It is quite hard to answer what is wrong here.
Can you post your shader?
from diligentengine.
blow is outline of fragment shader code ,all code within macro is not activated
struct ParticleCB {
float4x4 previous_view_projection, previous_inverse_view_projection;
float4 forward;
ShaderFrustum frustum;
uint texture_depth_index_prev;
int texture_primitiveID_index;
int texture_depth_index;
int texture_lineardepth_index;
int texture_velocity_index;
#ifndef __cplusplus
inline float4 internal_resolution(){
return g_CameraAttribs.f4ViewportSize;
}
inline float3 forwardf(){
return forward;
}
inline float4x4 view(){
return g_CameraAttribs.mView;
}
#endif // __cplusplus
};
#define GetCamera() g_xCamera
#define texture_depth bindless_textures_float[GetCamera().texture_depth_index]
cbuffer cbParticleAttribs
{
ParticleCB g_xCamera;
};
struct VertextoPixel
{
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
nointerpolation float size : TEXCOORD1;
nointerpolation uint color : TEXCOORD2;
float3 P : WORLDPOSITION;
nointerpolation float frameBlend : FRAMEBLEND;
float2 unrotated_uv : UNROTATED_UV;
};
StructuredBuffer<ShaderMaterial> materials;
StructuredBuffer<ShaderGeometry> geometrys;
Texture2D<float> bindless_textures_float[1];
ShaderMaterial EmitterGetMaterial()
{
return materials[xEmitterInstanceIndex];
}
float4 Sampless(in ShaderTextureSlot ss, in SamplerState sam, in float4 uvsets)
{
Texture2D tex = bindless_textures[ss.texture_descriptor];
float2 uv = ss.GetUVSet() == 0 ? uvsets.xy : uvsets.zw;
#ifndef DISABLE_SVT
[branch]
if (sparse_residencymap_descriptor >= 0)
{
Texture2D<uint> residency_map = bindless_textures_uint[UniformTextureSlot(sparse_residencymap_descriptor)];
float2 virtual_tile_count;
residency_map.GetDimensions(virtual_tile_count.x, virtual_tile_count.y);
float2 virtual_image_dim = virtual_tile_count * SVT_TILE_SIZE;
float virtual_lod = get_lod(virtual_image_dim, ddx(uv), ddy(uv));
return SampleVirtual(tex, sam, uv, residency_map, virtual_tile_count, virtual_image_dim, virtual_lod);
}
#endif // DISABLE_SVT
return tex.Sample(sam, uv);
}
#define texture_lineardepth (bindless_textures_float[GetCamera().texture_lineardepth_index])
[earlydepthstencil]
float4 frag(VertextoPixel input) : SV_TARGET
{
ShaderMaterial material = EmitterGetMaterial();
float4 color = 1;
[branch]
if (material.textures[BASECOLORMAP].IsValid())
{
color = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.xyxy);
[branch]
if (xEmitterOptions & EMITTER_OPTION_BIT_FRAME_BLENDING_ENABLED)
{
float4 color2 = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.zwzw);
color = lerp(color, color2, input.frameBlend);
}
}
float2 pixel = input.pos.xy;
float2 ScreenCoord = pixel * internal_resolution().zw;
float4 depthScene = compute_lineardepth(texture_lineardepth.GatherRed(bindless_textures_sampler, ScreenCoord)) ;//* g_CameraAttribs.fFarPlaneZ;
float depthFragment = input.pos.w;
float fade = saturate(1.0 / input.size * (max(max(depthScene.x, depthScene.y), max(depthScene.z, depthScene.w)) - depthFragment));
float4 inputColor;
inputColor.r = ((input.color >> 0) & 0xFF) / 255.0f;
inputColor.g = ((input.color >> 8) & 0xFF) / 255.0f;
inputColor.b = ((input.color >> 16) & 0xFF) / 255.0f;
inputColor.a = ((input.color >> 24) & 0xFF) / 255.0f;
float opacity = saturate(color.a * inputColor.a * fade);
color.rgb *= inputColor.rgb * (1 + material.GetEmissive());
color.a = opacity;
#ifdef EMITTEDPARTICLE_DISTORTION
// just make normal maps blendable:
color.rgb = ApplySRGBCurve_Fast(color.rgb); // note: This texture uses basecolormap slot, and this slot is using SRGB descriptor, so we correct it here for normal map
color.rgb = color.rgb - 0.5f;
#endif // EMITTEDPARTICLE_DISTORTION
#ifdef EMITTEDPARTICLE_LIGHTING
[branch]
if (color.a > 0)
{
float3 N;
N.x = -cos(PI * input.unrotated_uv.x);
N.y = cos(PI * input.unrotated_uv.y);
N.z = -sin(PI * length(input.unrotated_uv));
N = mul((float3x3)GetCamera().inverse_view, N);
N = normalize(N);
Lighting lighting;
lighting.create(0, 0, GetAmbient(N), 0);
Surface surface;
surface.init();
surface.create(material, color, 0);
surface.P = input.P;
surface.N = N;
surface.V = 0;
surface.pixel = pixel;
surface.sss = material.subsurfaceScattering;
surface.sss_inv = material.subsurfaceScattering_inv;
surface.update();
TiledLighting(surface, lighting);
color.rgb *= lighting.direct.diffuse + lighting.indirect.diffuse;
//color.rgb = float3(unrotated_uv, 0);
//color.rgb = float3(input.tex, 0);
color = max(0, color);
}
#endif // EMITTEDPARTICLE_LIGHTING
return color;
}
from diligentengine.
but I have binded buffer with code
Do you create SRB after you set the variable?
If you first create an SRB and then set the variable in PSO, it will not be reflected in SRB
from diligentengine.
I'm bind variable to PSO then create SRB. post some snippet
```
{
auto& Renderpsbi = PSBs[(int)PSBID::EMITRender];
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_VERTEX, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "EmittedParticleCB")->
Set(vbufs[(int)mybuffname::cbEmittedParticle]);
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "bindless_textures_float")
->SetArray(bindless_texf, 0, 1));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbParticleAttribs")
->Set(vbufs[(int)mybuffname::cbParticleAttribs]));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials")
->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));
}
for (size_t i = 0; i < PSBs.size(); i++)
{
PSBs[i].CreateShaderResourceBinding();
}
from diligentengine.
I can't tell what is the issue.
Try comparing your code with Tutorial 14 and Tutorial 16
from diligentengine.
THANKS you reply. use SRB instead
from diligentengine.
Related Issues (20)
- How to Transfer Variables from Vertex Shaders to Pixel Shaders in HLSL, Similar to Opengl's Vary HOT 1
- Tutorial19Application_RenderPass crash on android HOT 2
- Why does the projection matrix appear to be in a left-hand coordinate system HOT 5
- Hello, we want to use DiligentEngine as a part of commercial software, which has just started to develop. Is there anything we should pay attention to HOT 2
- Why do objects display in a left-hand coordinate system HOT 7
- WebGPU support. HOT 4
- Macro is too much , Affects code readability HOT 1
- Poor API design choices affect real usability HOT 2
- Build failure on linux
- Windows build output HOT 7
- Wordpress site hijacked HOT 1
- Build Failure Involving libpng in DiligentEngine HOT 6
- Is build multiple shader in differrent thread safe? HOT 1
- windows build error HOT 2
- Website appears to have been hacked HOT 1
- DX11 crash when changing max frame latency HOT 4
- Build failure with FetchContent HOT 14
- Multiple swap chains frame lag? HOT 4
- read wrong depth from stage texture? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diligentengine.